/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.feiyue.basic.reader.pojo.Chapter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ChapterDao extends Dao {
	private static final String COMPERE = "chapter";

	public ChapterDao(Context paramContext) {
		super(paramContext);
		this.db.setTableName("chapter");
	}

	private List<Chapter> getList(Cursor paramCursor) {
		ArrayList localArrayList = new ArrayList();
		paramCursor.moveToFirst();
		while (true) {
			if (paramCursor.isAfterLast()) {
				paramCursor.close();
				return localArrayList;
			}
			localArrayList.add(new Chapter());
			paramCursor.moveToNext();
		}
	}

	public void delete(long paramLong) {
		this.db.delete(paramLong);
	}

	public String getApi(String paramString, long paramLong) {
		return paramString + "_" + paramLong;
	}

	public List<Chapter> getList() {
		return getList(this.db.query(new String[] { "id", "title", "words",
				"nid", "ctno", "cid", "path" }, null, null, null, null, null));
	}

	public List<Chapter> getList(String paramString) {
		return getList(this.db.query(new String[] { "id", "title", "words",
				"nid", "ctno", "cid", "path" }, "path = ?",
				new String[] { paramString }, null, null, null));
	}

	public void save(Chapter paramChapter) {
		List localList = getList(paramChapter.getPath());
		ContentValues localContentValues = new ContentValues();
		if (localList.size() != 0)
			return;
		this.db.insert(localContentValues);
	}

	public void save(List<Chapter> paramList) {
		Iterator localIterator = paramList.iterator();
		while (true) {
			if (!(localIterator.hasNext()))
				return;
			save((Chapter) localIterator.next());
		}
	}
}